Home

Computer science

'

Modify this program so that it writes the values in two columns, like this:
\ufeff 32.00   54.00
\ufeff 67.50   29.00
\ufeff 35.00   80.00
\ufeff 115.00   44.50
\ufeff 100.00   65.00
Total: 622.00
#include
#include
#include
#include
using namespace std;
int main()
{
\ufeff // \ufeffPrompt for the input and output file names
\ufeff cout << \ufeff"Input file: " << \ufeffendl;
\ufeff string input_file; cin >> \ufeffinput_file;
\ufeff cout << \ufeff"Output file: " << \ufeffendl;
\ufeff string output_file; cin >> \ufeffoutput_file;
\ufeff // \ufeffConstruct the streams for reading and writing
\ufeff ifstream in(input_file);
\ufeff ofstream out(output_file);
\ufeff // \ufeffCheck for errors and format the output stream
\ufeff if (in.fail() || \ufeffout.fail()) { \ufeffreturn - 1; }
\ufeff out << \ufefffixed << \ufeffsetprecision(2);
\ufeff
\ufeff // \ufeffRead the input and write the output
\ufeff double total = 0;
\ufeff double value;
\ufeff while (in >> \ufeffvalue)
\ufeff {
\ufeff out << \ufeffsetw(15) << \ufeffvalue << \ufeffendl;
\ufeff total = \ufefftotal + \ufeffvalue;
\ufeff }
\ufeff out << \ufeff"Total: " << \ufeffsetw(8) << \ufefftotal << \ufeffendl;
\ufeff return 0;
}





'

Answer